import { message } from 'ant-design-vue'

export const loading = (text: string = '加载中...') => {
  return function (
    target: { [key: string]: any },
    name: string,
    descriptor: { [key: string]: any }
  ) {
    const fn = descriptor.value
    descriptor.value = async function (...opt: any[]) {
      const load = message.loading(text)
      const res = await fn.call(this, ...opt)
      load()
      return res
    }
  }
}
